<?php

/*
 * Action
 * 
 * +1 Card; +1 Action
 * 
 * While this is in play, cards cost $1 less, but not less than $0.
 * 
 */

class Highway extends Card implements iKingdom, iHinterlands, iAction, iInfluence {

    public function __construct() {
        parent::__construct("Highway", 5);
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "While this is in play, cards cost $1 less, but not less than $0.");
    }

    public function getDisplayName($quantity = 1) {
        if ($quantity == 1) {
            return "Highway";
        }
        return $quantity . " Highways";
    }

    public function play(Game $game, $isRealCard) {
        // +1 card; +1 action
        $game->addActions(1);
        $drawed_cards = $game->drawCards(1);
        ScreenDisplay::addScreenMessage($game, true, "get +1 action and draw " . nicePrint($drawed_cards), "gets +1 action and draws " . sizeof($drawed_cards) . " cards");

        if ($isRealCard == REAL_CARD) {
            $game->pushCardToInfluence($this);
            $this->influence($game);
        }
    }

    public function influence(Game $game) {
        $names = $game->getPlayersNames();
        foreach ($names as $name) {
            $cards = $game->getAllCards($name);
            foreach ($cards as $card) {
                $price = $card->getPrice($game);
                $new_price = $price->add(-1);
                $card->setPrice($new_price);
            }
        }
        $boardCards = $game->getAllBoardIncludingEmptyPiles(true);
        foreach ($boardCards as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-1);
            $card->setPrice($new_price);
        }

        $trashCards = $game->getTrash();
        foreach ($trashCards as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-1);
            $card->setPrice($new_price);
        }
    }

}

?>
